require 'rubygems'
require 'ferret'

include Ferret

class SearchIndex

	@@bulas_index = Index::Index.new(:path => './bulario.idx')  

	def self.by_symptom(symptom)

		print "\n"
		print " " + "Medicamento/Pagina".ljust(20)
		print " " + "URL".center(40)
		print " " + "Score".rjust(20) + "\n"
		puts "-" * 85

		@@bulas_index.search_each("indications: #{symptom}") do | id, score |  
			line = " " << @@bulas_index[id][:drug].ljust(22)
			line << " " + @@bulas_index[id][:url].ljust(40)
			line << " " + score.to_s.rjust(20)
			puts line
		end  

		print "\n"
	end

end
